<?php
include("include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  header("location:checklogin.php");
}

$i=0;
$unloadArray = array();
$selectunload = "SELECT loadinginvoice.truckId,unload.invoiceNo,unload.unloadfrom,loadinginvoice.toId,unload.unloadId,unload.unloadInvNo,
                        DATE_FORMAT(loadinginvoice.invoiceDate,'%d-%m-%Y')AS invoiceDate,
                        DATE_FORMAT(unload.unloadDate ,'%d-%m-%Y')AS unloadDate,branch.branchName,branchFrom.branchName AS fromBranchName
                   FROM unload
                   JOIN loadinginvoice ON loadinginvoice.invoiceNo = unload.invoiceNo
                   JOIN branch ON branch.branchId = loadinginvoice.toId
                   JOIN branch AS branchFrom ON branchFrom.branchId = loadinginvoice.fromId
               ORDER BY invoiceNo";
$selectunloadRes = mysql_query($selectunload);
while($unloadRow = mysql_fetch_array($selectunloadRes))
{
	$unloadArray[$i]['truckId']     = $unloadRow['truckId'];
	$unloadArray[$i]['invoiceNo']   = $unloadRow['invoiceNo'];
	$unloadArray[$i]['unloadId']    = $unloadRow['unloadId'];
	$unloadArray[$i]['unloadfrom']  = $unloadRow['fromBranchName'];
	$unloadArray[$i]['unloadTo']    = $unloadRow['branchName'];
	$unloadArray[$i]['unloadInvNo'] = $unloadRow['unloadInvNo'];
	$unloadArray[$i]['invoiceDate'] = $unloadRow['invoiceDate'];
	$unloadArray[$i]['unloadDate']  = $unloadRow['unloadDate'];
	$i++;
}

$i=0;

echo $selectunloadDel = "SELECT unloadDetailId,unloadId,unloadLrNo,consignor,consignee,weight,desco,toPay,
                                octroi,octroiNo,deliveryDate,cashMemoNo,lenarParty,grandTotal
                           FROM unloadDetail
                           WHERE unloadId = ".$_GET['unloadId']."
                       ORDER BY unloadId";
$selectunloadDelRes = mysql_query($selectunloadDel);
while($unloadDetailRow = mysql_fetch_array($selectunloadDelRes))
{
	$unloadDetailArray[$i]['unloadDetailId'] = $unloadDetailRow['unloadDetailId'];
	$unloadDetailArray[$i]['unloadId']       = $unloadDetailRow['unloadId'];
	$unloadDetailArray[$i]['unloadLrNo']     = $unloadDetailRow['unloadLrNo'];
	$unloadDetailArray[$i]['consignor']      = $unloadDetailRow['consignor'];
	$unloadDetailArray[$i]['consignee']      = $unloadDetailRow['consignee'];
	$unloadDetailArray[$i]['weight']         = $unloadDetailRow['weight'];
	$unloadDetailArray[$i]['desco']          = $unloadDetailRow['desco'];
	$unloadDetailArray[$i]['octroi']         = $unloadDetailRow['octroi'];
	$unloadDetailArray[$i]['octroiNo']       = $unloadDetailRow['octroiNo'];
	$unloadDetailArray[$i]['deliveryDate']   = $unloadDetailRow['deliveryDate'];
	$unloadDetailArray[$i]['cashMemoNo']     = $unloadDetailRow['cashMemoNo'];
	$unloadDetailArray[$i]['lenarParty']     = $unloadDetailRow['lenarParty'];
	$unloadDetailArray[$i]['grandTotal']     = $unloadDetailRow['grandTotal'];
	$i++;
}

include("./bottom.php");
$smarty->assign("unloadArray",$unloadArray);
$smarty->assign("unloadDetailArray",$unloadDetailArray);
$smarty->display("unloadingregisterDetail.tpl");
?>
